package org.rambadger.command.event;

import com.google.common.base.Objects;

import java.io.Serializable;

public abstract class FileUploaded {
    final String filename;
    final String fileId;

    protected FileUploaded(String filename, String fileId) {
        this.filename = filename;
        this.fileId = fileId;
    }


    public String getFilename() {
        return filename;
    }

    public String getFileId() {
        return fileId;
    }


    public static class SubmissionFileUploaded extends FileUploaded implements Serializable {
        private static final long serialVersionUID = -1283932470833063220L;
        //Compound Key {
        final String submitterId;
        final int submissionId;
        //}

        public SubmissionFileUploaded(String submitterId, int submissionId, String filename, String fileId) {
            super(filename, fileId);
            this.submitterId = submitterId;
            this.submissionId = submissionId;
        }

        public String getFullSubmissionId() {
            return submitterId+"/"+submissionId;
        }

        public String getSubmitterId() {
            return submitterId;
        }

        public int getSubmissionId() {
            return submissionId;
        }

        @Override
        public String toString() {
            return Objects.toStringHelper(this)
                    .add("submitterId", submitterId)
                    .add("submissionId", submissionId)
                    .add("filename", filename)
                    .add("fileId", fileId)
                    .toString();
        }
    }

    public static class AssignmentFileUploaded extends FileUploaded implements Serializable {
        private static final long serialVersionUID = -8459265438756038666L;
        //Compound Key {
        final String platformId;
        final String assignmentId;
        //}

        public AssignmentFileUploaded(String platformId, String assignmentId, String filename, String fileId) {
            super(filename, fileId);
            this.platformId = platformId;
            this.assignmentId = assignmentId;
        }

        public String getPlatformId() {
            return platformId;
        }

        public String getAssignmentId() {
            return assignmentId;
        }

        @Override
        public String toString() {
            return Objects.toStringHelper(this)
                    .add("platformId", platformId)
                    .add("assignmentId", assignmentId)
                    .add("filename", filename)
                    .add("fileId", fileId)
                    .toString();
        }
    }


    public static class UserPortraitChanged extends FileUploaded implements Serializable {
        private static final long serialVersionUID = 1996093809696380714L;

        final String username;


        public UserPortraitChanged(String username, String filename, String fileId) {
            super(filename, fileId);
            this.username = username;
        }

        public String getUsername() {
            return username;
        }

        @Override
        public String toString() {
            return Objects.toStringHelper(this)
                    .add("username", username)
                    .add("filename", filename)
                    .add("fileId", fileId)
                    .toString();
        }
    }
}
